#!/bin/sh
#docker save $(docker images --format '{{.Repository}}:{{.Tag}}') -o allinone.tar
function save() {
    IMAGES=$(docker images --format '{{.Repository}}:{{.Tag}}')

for element in ${IMAGES[@]}
do

  array=(`echo ${element}| tr ':' ' '` )

  software=${array[0]}
  version=${array[1]}
  mkdir -p dockerimages
  software2=$(echo $software|sed 's#/#=#g')
  docker save ${software}:${version} > dockerimages/${software2}_${version}
  tar zcvf dockerimages.tar.gz dockerimages
done
}

function load() {
  tar zxvf dockerimages.tar.gz
  IMAGES=$(ls dockerimages)

for element in ${IMAGES[@]}
do
  array=(`echo ${element}| tr '_' ' '` )
  software=${array[0]}
  version=${array[1]}
  software2=$(echo $software|sed 's#=#/#g')
  echo "docker load <${element}"
  docker load <dockerimages/${element}
done

}

load